/**
 * Created by billy on 2020/7/1.
 */
var _containerList = ["div", "section", "p"];

module.exports = function ($node, $createAttribs, $createHtml, $type = "view")
{
	var tagName = $node.name;
	var hasContainer = false;
	for (var item of $node.children)
	{
		if (item.type == "tag")
		{
			if (_containerList.indexOf(item.name) >= 0)
			{
				hasContainer = true;
			}
		}
	}
	if (hasContainer)
	{
		tagName = $type == "view" ? "div" : "p";
	}
	return `<${tagName}${createAttribs($node, $createAttribs, $type)}>${$createHtml($node.children, $type)}</${tagName}>`;
}

function createAttribs($node, $createAttribs, $type)
{
	var attribs = $node.attribs;
	if (attribs.label)
	{
		delete attribs.label;
	}
	return $createAttribs($node, $type);
}